import threading
import datetime
from SimDisMeasurment import * 
from SimilarityEnum import *
from ReadWrite import *
from copy import *

class ThreadClass(threading.Thread):
  
  def __init__(self, datadict2, user, measurement):
      threading.Thread.__init__(self)
      self.datadict2 = datadict2
      self.user = user
      self.measurment = measurement
      self.nnlist = []
      
      
  def run(self):
    for neig, neighbor in self.datadict2.iteritems():
        
        if self.measurment == SimilarityEnum.Hamming:
            distance = hammingSimilarity(self.user, neighbor)
        elif self.measurment == SimilarityEnum.Cosine:
            distance = cosineSimilarity(self.user, neighbor)
        elif self.measurment == SimilarityEnum.Jaccard:
            distance = jaccardSimilarity(self.user, neighbor)
        
        #print(distance)
        self.nnlist.append((neig, distance))
     
  def getList(self):
      return self.nnlist
    
  def getdict(self):
      return self.nn_forall
'''
for i in range(2):
  t = ThreadClass()
  t.start()
'''